<style lang="scss" scoped>
</style>

<template>
    <div class="topbar">
        <span class="leftbtn" @click="goback"><Icon type="ios-arrow-back"></Icon></span>
        <span class="centertitle">{{title}}</span>
        <span class="rightbtn" @click="edit" v-show="topBarParam.btnEdit">编辑</span>   
        <span class="rightbtn" @click="del" v-show="topBarParam.btnEdit">删除</span>  
        <span class="rightbtn" @click="save" v-show="!topBarParam.btnEdit">保存</span>  
    </div>
</template>

<script>
export default {
  props: ["title"],
  data() {
    return {
      topBarParam: {
        btnEdit: false,  //控制编辑按钮是否出现
      }
    };
  },
  methods: {
    goback() {
      this.$router.go(-1);
    },
    edit() {
        this.topBarParam.btnEdit=false;
        this.$emit('changeStatus',this.topBarParam);
    },
    del(){
      this.$emit('delItem');
    },
    save() {
      this.$emit('saveItem');
    }
  },
  mounted() {
    if(this.$store.state.agentOperation=='edit'){
          this.topBarParam.btnEdit=true;
    }else{
          this.topBarParam.btnEdit=false;
    }
  },
};
</script>

